package com.webtest.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/8/13 15:42
 */
public class WhenTag extends SimpleTagSupport {
    private boolean test;

    public void setTest(boolean test) {
        this.test = test;
    }

    @Override
    public void doTag() throws JspException, IOException {
        ChooseTag parent = (ChooseTag) getParent();

        boolean flag = parent.getFlag();
        if (flag && test) {
            getJspBody().invoke(null);
            parent.setFlag(false);
        }
    }
}
